﻿@model XSTDZ.ERP.Application.DataContracts.ClientInfoDto
@using XSTDZ.ERP.Infrastructure.Extentions
@{
    ViewBag.Title = " - 添加经销商";
}
@section header{
     <link href="@Url.Content("~/Content/Controls.css")" rel="stylesheet" type="text/css" />
 <link href="@Url.Content("~/Content/Form.css")" rel="stylesheet" type="text/css" />
}
<h2>添加经销商</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
 <table class="formtable">
    <thead>
        <tr>
            <th colspan="4">
            <div id="toptoolbar"></div>
            </th>
        </tr>
    </thead>
    <tr>
          <td class="title"> @Html.LabelFor(model => model.ClientName)<b>*</b></td>
        <td> @Html.TextBoxFor(model => model.ClientName, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.ClientName)
          @Html.HiddenFor(model => model.Id)
           @Html.HiddenFor(model => model.CreateID)
           @Html.HiddenFor(model => model.CreateTime)
         <input id="HidOrgCode" name="HidOrgCode" type="hidden" value="@ViewBag.orgCode" />
        </td>

        <td class="title">@Html.LabelFor(model => model.ClientCode)</td>
        <td>  @Html.TextBoxFor(model => model.ClientCode, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.ClientCode)
         </td>
    </tr>

     <tr>
          <td class="title"> @Html.LabelFor(model => model.ShortName)</td>
        <td> @Html.TextBoxFor(model => model.ShortName, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.ShortName)
        </td>

        <td class="title"></td>
        <td> 
         </td>
    </tr>

     <tr>
          <td class="title"> @Html.LabelFor(model => model.ProvincialID)</td>
        <td>
        @* @Html.TextBoxFor(model => model.ProvinceName, new { @class = "text" })*@
         @Html.DropDownListFor(model => model.ProvincialID, ViewBag.Provoices as IEnumerable<SelectListItem>, new { @class = "select" })
          @Html.HiddenFor(model => model.ProvincialID)
        @Html.ValidationMessageFor(model => model.ProvincialID)
        </td>

        <td class="title">@Html.LabelFor(model => model.CityID)</td>
        <td> @* @Html.TextBoxFor(model => model.CityName, new { @class = "text" })*@
       @Html.DropDownListFor(model => model.CityID, ViewBag.Cities as IEnumerable<SelectListItem>, new { @class = "select" })
        @Html.HiddenFor(model => model.CityID)
            @Html.ValidationMessageFor(model => model.CityID)
         </td>
    </tr>

     <tr>
          <td class="title"> @Html.LabelFor(model => model.ClientAddress)</td>
        <td> @Html.TextBoxFor(model => model.ClientAddress, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.ClientAddress)
        </td>

        <td class="title">@Html.LabelFor(model => model.PostCode)</td>
        <td>  @Html.TextBoxFor(model => model.PostCode, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.PostCode)
         </td>
    </tr>

     <tr>
          <td class="title"> @Html.LabelFor(model => model.Http)</td>
        <td> @Html.TextBoxFor(model => model.Http, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.Http)
        </td>

        <td class="title">@Html.LabelFor(model => model.ClientPhone)</td>
        <td>  @Html.TextBoxFor(model => model.ClientPhone, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.ClientPhone)
         </td>
    </tr>
    <tr>

        <td class="title">@Html.LabelFor(model => model.ClientFax)</td>
        <td>  @Html.TextBoxFor(model => model.ClientFax, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.ClientFax)
         </td>
  

        <td class="title">@Html.LabelFor(model => model.Email)</td>
        <td>  @Html.TextBoxFor(model => model.Email, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.Email)
         </td>
    </tr>

     <tr>
          <td class="title"> @Html.LabelFor(model => model.BankName)</td>
        <td> @Html.TextBoxFor(model => model.BankName, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.BankName)
        </td>

        <td class="title">@Html.LabelFor(model => model.AccountNnmber)</td>
        <td>  @Html.TextBoxFor(model => model.AccountNnmber, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.AccountNnmber)
         </td>
    </tr>

     <tr>
          <td class="title"> @Html.LabelFor(model => model.Describe)</td>
        <td> @Html.TextBoxFor(model => model.Describe, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.Describe)
        </td>

        <td class="title">@Html.LabelFor(model => model.ClientProperty)</td>
        <td> 
        @Html.DropDownListFor(model => model.ClientProperty, ViewBag.ClientProperty as IEnumerable<SelectListItem>, new { @class = "select"})
            @Html.ValidationMessageFor(model => model.ClientProperty)
         </td>
    </tr>
     <tr>
          <td class="title"> @Html.LabelFor(model => model.ResponsibleDeptID)<b>*</b></td>
        <td>
        @Html.TextBoxFor(model => model.ResponsibleDeptName, new { @class = "text" })
         @Html.HiddenFor(model => model.ResponsibleDeptID) <a href="javascript:void(0);" onclick="javascript:selectOrg();" >选择</a>
        @Html.ValidationMessageFor(model => model.ResponsibleDeptID)
        </td>

        <td class="title">@Html.LabelFor(model => model.ResponsiblePersonID)<b>*</b></td>
        <td>  @Html.TextBoxFor(model => model.ResponsiblePersonName, new { @class = "text" })
         @Html.HiddenFor(model => model.ResponsiblePersonID)
            @Html.ValidationMessageFor(model => model.ResponsiblePersonID)
         </td>
    </tr>

    <tr>
          <td class="title"> @Html.LabelFor(model => model.Remarks)</td>
        <td> @Html.TextBoxFor(model => model.Remarks, new { @class = "text" })
        @Html.ValidationMessageFor(model => model.Remarks)
        </td>
        <td class="title"></td>
        <td> 
         </td>
    </tr>
     <tr>
        <td  colspan="4" style=" overflow:hidden; text-align:left; height:50px;">
         <p class="divBtn"  style=" position:inherit; float:left; margin:5px 0 0 0;">
               <input type="hidden" id="hidHttpRefeParent" name="hidHttpRefeParent" value="grid" />
         <input type="hidden" id="hidHttpPostState" name="hidHttpPostState" value="@ViewBag.PostState" />
            <input type="submit" value="@XSTDZ.ERP.Infrastructure.SystemConfig.BtnSave"  class="BtnSubmit" id="submitBtn" name="submitBtn" />
            <input type="button" value="@XSTDZ.ERP.Infrastructure.SystemConfig.BtnClose" id="btnFromClose" name="btnFromClose" class="BtnClose" />
        </p>
           </td>
    </tr>
    </table>
}

<div class="wp100">
<div id="ClitentLinksGrid" style="margin-top:20px" ></div>
</div>



<script type="text/javascript">
    $(document).ready(function () {
        $("#ProvincialID").unbind("change").bind("change", selectCity);
    });
    //选择省级，市级联动变化 --开始
    function selectCity() {
        var pval = $("#ProvincialID").val();
        if (pval != undefined) {
            if ($.trim(pval).length > 0) {
                $.get("../Client/GetCityListOfJson", { cityId: pval }, function (data) {
                    if (data != undefined && data != null) {
                        addCityOption(data);
                    }
                });

            }
        }
    }
    function addCityOption(cityJson) {
        var cityOpts = "";
        cityJson = eval(cityJson);//编码
        $.each(cityJson,function (i, item) {
            cityOpts += "<option value=\"" + item.Value + "\" selected=\"" + (item.Selected ? "selected" : "") + "\">" + item.Text + "</option>";
        });
        var $city = $("#CityID");
        if ($city != undefined) {
            $city.html("").html(cityOpts);
        }
    }
    //选择省级，市级联动变化 --结束
     function f_buttonclick_OK() {
                  alert('弹出框，然后选择项，调用setValue和setText方法');
                  var pop = this;
                  this.setValue('1');
                  this.setText('弹出框选取的值');
              } 
    function PostData() {
        
            var btnText = $("#submitBtn").val();
            $("#submitBtn").val("").val("正在处理中...");
            $.ajax({ type: "POST", url: "/Client/Add", data: $('form').serialize(), // 要提交的表单
                success: function (msg) {
                    if (msg == "9") {
                        $.ligerDialog.success('操作成功!');
                        initligerGrid();
                    }
                    else if (msg == "-1") {
                        $.ligerDialog.success('入库单明细数据不完整,操作失败!');
                    }
                    else {
                        $.ligerDialog.success('操作失败!');
                    }
                    $("#submitBtn").val("").val(btnText);
                }
            });

        }
        function selectOrg() {
            var returnValue = window.showModalDialog('../Org/SelectOrgTree', window, "help:No;resizable:No;status:No;scroll:yes;dialogWidth=300px;dialogHeight=300px");
            $("#ResponsibleDeptName").val(returnValue[0]);
            $("#ResponsibleDeptID").val(returnValue[1]);

        }
</script>
 
<script type="text/javascript" src="@Url.Content("~/Scripts/ligerUI/js/plugins/ligerPopupEdit.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/formBase.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/Client/SelectData.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/Client/Add.js")"></script>